#include <WindowBase.h>

WindowBase::WindowBase( QWidget *parent /*= 0*/, Qt::WindowFlags flags /*= Qt::Window*/ )
{
    m_windowShowHideAction = new QAction(" ",this);
    m_windowShowHideAction->setCheckable(true);
    m_dockWidget = NULL;
    m_initialShow = true;
}

WindowBase::~WindowBase()
{

}

Qt::DockWidgetArea WindowBase::dockWidgetArea()
{
    return Qt::DockWidgetArea::LeftDockWidgetArea;
}

QList<QAction *> WindowBase::getActionList()
{
    QList<QAction*> action_list;
    return action_list;
}

QMenu *WindowBase::getWindowBaseMenu()
{
    return NULL;
}

QAction *WindowBase::getWindowShowHideAction()
{
    return m_windowShowHideAction;
}

QDockWidget *WindowBase::getDockWidget()
{
    if(m_dockWidget == NULL)
    {
        m_dockWidget = new QDockWidget;
        m_dockWidget->setWidget(this);
        connect(m_windowShowHideAction, SIGNAL(toggled (bool)), this, SLOT(windowShowHideActionToggled(bool)));

    }
    return m_dockWidget;
}

bool WindowBase::getInitialShow()
{
    return m_initialShow;
}

void WindowBase::setUpInitialShowHide()
{

}

void WindowBase::reDock()
{
    WindowBase::getDockWidget()->setWidget(this);
}

void WindowBase::windowShowHideActionToggled(bool checked)
{
    if(checked == true)
    {
        m_dockWidget->show();
    }
    else
    {
        m_dockWidget->hide();
    }
}
